package com.yhy.wxzn.wcs.wcsWmsCommunication.bean;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum WmsTaskStatus {

    RECEIVED(0, "已接收"),
    START(1, "任务开始"),
    GET_FINISH(2, "取货完成"),
    INTERRUPT(3, "任务中断"),
    PUT_FINISH(4, "放货完成"),
    FINISH(8, "任务结束"),
    EMPTY_PALLET(9, "取拖无拖"),
    CANCEL(10, "任务取消"),
    EXIST_PALLET(11, "存拖有拖");


    @EnumValue
    private int taskProgress;
    @JsonValue
    private String description;



    @Override
    public String toString() {
        return description;
    }

    public static WmsTaskStatus parseTaskProgress(int taskProgress) {
        WmsTaskStatus[] taskProgresses = WmsTaskStatus.values();
        for (WmsTaskStatus progress : taskProgresses) {
            if (progress.taskProgress == taskProgress) {
                return progress;
            }
        }
        throw new IllegalArgumentException("任务进度参数异常");
    }


    public static WmsTaskStatus parseTaskProgress(String description) {
        WmsTaskStatus[] taskProgresses = WmsTaskStatus.values();
        for (WmsTaskStatus progress : taskProgresses) {
            if (progress.description.equals(description)) {
                return progress;
            }
        }
        throw new IllegalArgumentException("任务进度描述异常");
    }



}
